require(['./config'], () => {
  require(['request','header','footer','jquery','bootstrap'], (request) => {
    class Register {
      constructor() {
        this.goReg()
      }
      goReg() {
        $('#go').on('click', function() {
          let userName = $('#userName').val()
          let password = $('#password').val()
          let list = { name:userName, pwd:password}
          let userList = JSON.parse(localStorage.getItem('userList'))
          if(userList) {
            let flag = userList.some(item =>{
              return item.name === userName && item.pwd === password
            })
            if(flag) {
              alert('账户已经被注册！')
            } else{
              userList.push(list)
              localStorage.setItem('userList', JSON.stringify(userList))
              window.open('loginPage.html')
            }
          }else{
            localStorage.setItem('userList', JSON.stringify([list]))
            window.open('loginPage.html')
          }
        })
      }
    }
    new Register
  })
})